package itsec1.api.services;

import java.io.Serializable;

public class AllowedRequests implements Serializable{
	private static final long serialVersionUID = -5999850148576611841L;
	
	//READ RIGHTS
	//personal data: customerid, firstname, lastname, sex
	private boolean readPersonalData= false;
	//address data: zipcode, address
	private boolean readAddressData= false;
	//contact data: email, phone
	private boolean readContactData= false;
	//password: password
	private boolean readPassword= false;
	//closed data:
	private boolean readClosedData= false;
	//card data:
	private boolean readCardData= false;
	
	//WRITE RIGHTS
	private boolean writePersonalData= false;
	private boolean writeAddressData= false;
	private boolean writeContactData= false;
	private boolean writePasswordData= false;
	private boolean deleteCustomer= false;
	private boolean deleteCard= false;
	private boolean insertCustomer= false;
	private boolean writeCardLimitData= false;
	private boolean insertCard= false;
	private boolean registerUser= false;
	private boolean unregisterUser= false;
	
	public AllowedRequests(){
		
	}
	
	public AllowedRequests(boolean readPersonalData, boolean readAddressData,
			boolean readContactData, boolean readPassword,
			boolean readClosedData, boolean readCardData,
			boolean writePersonalData, boolean writeAddressData,
			boolean writeContactData, boolean writePasswordData,
			boolean deleteCustomer, boolean deleteCard, 
			boolean insertCustomer,	boolean writeCardLimitData, 
			boolean insertCard, boolean registerUser, boolean unregisterUser) {
		this.readPersonalData = readPersonalData;
		this.readAddressData = readAddressData;
		this.readContactData = readContactData;
		this.readPassword = readPassword;
		this.readClosedData = readClosedData;
		this.readCardData = readCardData;
		this.writePersonalData = writePersonalData;
		this.writeAddressData = writeAddressData;
		this.writeContactData = writeContactData;
		this.writePasswordData= writePasswordData;
		this.deleteCustomer = deleteCustomer;
		this.deleteCard = deleteCard;
		this.insertCustomer = insertCustomer;
		this.writeCardLimitData = writeCardLimitData;
		this.insertCard = insertCard;
		this.registerUser= registerUser;
		this.unregisterUser= unregisterUser;
	}

	public boolean isReadPersonalData() {
		return readPersonalData;
	}

	public void setReadPersonalData(boolean readPersonalData) {
		this.readPersonalData = readPersonalData;
	}

	public boolean isReadAddressData() {
		return readAddressData;
	}

	public void setReadAddressData(boolean readAddressData) {
		this.readAddressData = readAddressData;
	}

	public boolean isReadContactData() {
		return readContactData;
	}

	public void setReadContactData(boolean readContactData) {
		this.readContactData = readContactData;
	}

	public boolean isReadPassword() {
		return readPassword;
	}

	public void setReadPassword(boolean readPassword) {
		this.readPassword = readPassword;
	}

	public boolean isReadClosedData() {
		return readClosedData;
	}

	public void setReadClosedData(boolean readClosedData) {
		this.readClosedData = readClosedData;
	}

	public boolean isReadCardData() {
		return readCardData;
	}

	public void setReadCardData(boolean readCardData) {
		this.readCardData = readCardData;
	}

	public boolean isWritePersonalData() {
		return writePersonalData;
	}

	public void setWritePersonalData(boolean writePersonalData) {
		this.writePersonalData = writePersonalData;
	}

	public boolean isWriteAddressData() {
		return writeAddressData;
	}

	public void setWriteAddressData(boolean writeAddressData) {
		this.writeAddressData = writeAddressData;
	}

	public boolean isWriteContactData() {
		return writeContactData;
	}

	public void setWriteContactData(boolean writeContactData) {
		this.writeContactData = writeContactData;
	}

	public boolean isWritePasswordData() {
		return writePasswordData;
	}

	public void setWritePasswordData(boolean writePasswordData) {
		this.writePasswordData = writePasswordData;
	}

	public boolean isDeleteCustomer() {
		return deleteCustomer;
	}

	public void setDeleteCustomer(boolean deleteCustomer) {
		this.deleteCustomer = deleteCustomer;
	}

	public boolean isDeleteCard() {
		return deleteCard;
	}

	public void setDeleteCard(boolean deleteCard) {
		this.deleteCard = deleteCard;
	}

	public boolean isInsertCustomer() {
		return insertCustomer;
	}

	public void setInsertCustomer(boolean insertCustomer) {
		this.insertCustomer = insertCustomer;
	}

	public boolean isWriteCardLimitData() {
		return writeCardLimitData;
	}

	public void setWriteCardLimitData(boolean writeCardLimitData) {
		this.writeCardLimitData = writeCardLimitData;
	}

	public boolean isInsertCard() {
		return insertCard;
	}

	public void setInsertCard(boolean insertCard) {
		this.insertCard = insertCard;
	}
	
	public boolean isRegisterUser() {
		return registerUser;
	}

	public void setRegisterUser(boolean registerUser) {
		this.registerUser = registerUser;
	}

	public boolean isUnregisterUser() {
		return unregisterUser;
	}

	public void setUnregisterUser(boolean unregisterUser) {
		this.unregisterUser = unregisterUser;
	}

	@Override
	public String toString(){
		String s= ""+
		readPersonalData+","+
		readAddressData+","+
		readContactData+","+
		readPassword+","+
		readClosedData+","+
		readCardData+","+
		
		writePersonalData+","+
		writeAddressData+","+
		writeContactData+","+
		writePasswordData+","+
		deleteCustomer+","+
		deleteCard+","+
		insertCustomer+","+
		writeCardLimitData+","+
		insertCard+","+
		registerUser+","+
		unregisterUser;
		
		return s;		
	}
	
	public AllowedRequests(String s){
		String[] split= s.split(",");
		int i=0;
		
		readPersonalData= split[i++].equals("true")? true : false;
		readAddressData= split[i++].equals("true")? true : false;
		readContactData= split[i++].equals("true")? true : false;
		readPassword= split[i++].equals("true")? true : false;
		readClosedData= split[i++].equals("true")? true : false;
		readCardData= split[i++].equals("true")? true : false;
		
		writePersonalData= split[i++].equals("true")? true : false;
		writeAddressData= split[i++].equals("true")? true : false;
		writeContactData= split[i++].equals("true")? true : false;
		writePasswordData= split[i++].equals("true")? true : false;
		deleteCustomer= split[i++].equals("true")? true : false;
		deleteCard= split[i++].equals("true")? true : false;
		insertCustomer= split[i++].equals("true")? true : false;
		writeCardLimitData= split[i++].equals("true")? true : false;
		insertCard= split[i++].equals("true")? true : false;
		registerUser= split[i++].equals("true")? true : false;
		unregisterUser= split[i++].equals("true")? true : false;
	}
}
